using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Acms.Bll
{
    public class SiteMapping : BaseItem
    {
        private SiteMapping() : base() { }
        private SiteMapping(Hashtable table) : base(table) { }
        private SiteMapping(Hashtable table, List<SiteMapping> collection) : base(table, collection) { }

        public static SiteMapping CreateInstance()
        {
            return new SiteMapping();
        }

        private static SiteMapping Get(Hashtable table)
        {
            if (table != null)
            {
                return new SiteMapping(table);
            }
            else
            {
                return null;
            }
        }

        private static List<SiteMapping> Get(Hashtable[] tables)
        {
            if (tables != null)
            {
                List<SiteMapping> tmp = new List<SiteMapping>();
                foreach (Hashtable table in tables)
                {
                    tmp.Add(new SiteMapping(table, tmp));
                }
                return tmp; 
            }
            else
            {
                return null;
            }
        }

        public static SiteMapping GetById(int id)
        {
            Acms.SqlDal.SiteMappingDal dal = new Acms.SqlDal.SiteMappingDal();
            return Get(dal.GetById(id));
        }

        public static List<SiteMapping> GetAllBySiteId(int siteId)
        {
            Acms.SqlDal.SiteMappingDal dal = new Acms.SqlDal.SiteMappingDal();
            return Get(dal.GetAllBySiteId(siteId));
        }

        public new void Delete()
        {
            base.Delete();
        }

        protected override void DeleteRecord(object concurencyId, Acms.SqlDal.Base dal)
        {
            ((Acms.SqlDal.SiteMappingDal)dal).Delete(id, concurencyId);
        }

        public new void Update()
        {
            base.Update();
        }

        protected override object SaveChanges(ref object concurencyId, Acms.SqlDal.Base dal)
        {
            ((Acms.SqlDal.SiteMappingDal)dal).Update(ref id, siteId, mappingName, ref concurencyId);
            return Id;
        }

        protected override void Load(Hashtable table)
        {
            id = (int)table[SqlDal.SiteMappingDal.Fields.Id];
            siteId = (int)table[SqlDal.SiteMappingDal.Fields.SiteId];
            mappingName = (string)table[SqlDal.SiteMappingDal.Fields.MappingName];
        }

        protected override Acms.SqlDal.Base CreateDal()
        {
            return new Acms.SqlDal.SiteMappingDal();
        }

        private int id;
        public int Id
        {
            get { return id; }
        }

        private int siteId;
        public int SiteId
        {
            get { return siteId; }
            set { siteId = value; }
        }

        private string mappingName;
        public string MappingName
        {
            get { return mappingName; }
            set { mappingName = value; }
        }
	
	
	
    }
}
